//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类.demo1AND20;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class demo17 {
    public demo17() {
    }

    public static void main(String[] args) {
        System.out.println(letterCombinations("7"));
    }

    public static List<String> letterCombinations(String digits) {
        if (digits != null && !digits.isEmpty()) {
            List<String> listStr = new ArrayList();
            String[][] nStr = new String[][]{{"a", "b", "c"}, {"d", "e", "f"}, {"g", "h", "i"}, {"j", "k", "l"}, {"m", "n", "o"}, {"p", "q", "r", "s"}, {"t", "u", "v"}, {"w", "x", "y", "z"}};
            listStr.addAll(Arrays.asList(nStr[digits.charAt(0) - 50]).subList(0, 3));
            if (digits.charAt(0) == '7' || digits.charAt(0) == '9') {
                listStr.add(nStr[digits.charAt(0) - 50][3]);
            }

            if (digits.length() == 1) {
                return listStr;
            } else {
                for(int i = 1; i < digits.length(); ++i) {
                    List<String> fStr = new ArrayList();

                    for(String s : listStr) {
                        for(int k = 0; k < nStr[digits.charAt(i) - 50].length; ++k) {
                            fStr.add(s + nStr[digits.charAt(i) - 50][k]);
                        }
                    }

                    listStr = fStr;
                }

                return listStr;
            }
        } else {
            return new ArrayList();
        }
    }
}
